﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.IO;
namespace database
{
    class Program
    {
        private static SortedList LoadProfanityList(string filename)
        {
            SortedList al = new SortedList();

            try
            {
                
                using (StreamReader sr = new StreamReader("profanitylist.txt"))
                {
                    
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        Console.WriteLine("{0}", line);
                        al.Add(line, line);
                    }
                }
                
            }
            catch(Exception e)
            {
                Console.WriteLine("error occured: {0} at {1}", e.Message, e.StackTrace);
            }
            return al;
        }
        static void Main(string[] args)
        {
           // FileStream F;
            string p = "profanitylist.txt";
            try
            {
                SortedList sl = LoadProfanityList(p);
                Console.WriteLine("the number of words is: {0}", sl.Count);
              //  F =  new FileStream(p, FileMode.Open, FileAccess.ReadWrite);
               // F.Close();
                Console.ReadKey();
                
            }
            catch (FileNotFoundException filenotfounde)
            {
                Console.WriteLine("file {0} not found and error : {1}", p,filenotfounde.Message);
            }
            catch(Exception e)
            {
                Console.WriteLine("error occured : {0}\n {1}",e.Message, e.StackTrace);
            }
            
            
          //  for (int i = 1; i <= 20; i++)
          //  {
                //F.WriteByte((byte)i);
           // }

           // F.Position = 0;

           // for (int i = 0; i <= 20; i++)
           // {
               // Console.Write(F.ReadByte() + " ");
           // }
           
           
        }
    }
}
